<template>
  <div class="thumbnail">
    <template v-if="!src">
      <div class="thumbnail-default">
        <img class="thumbnail-default-avatar" :src="avatar" alt="default" />
        <span v-if="windowWidth >= 1200" class="thumbnail-default-tooltip">暂无封面</span>
      </div>
    </template>
    <template v-else>
      <img class="thumbnail-image" :src="src" alt="thumbnail" />
    </template>
  </div>
</template>

<script>
import window from '../mixins/window';
export default {
  name: 'Thumbnail',
  mixins: [
    window
  ],
  props: {
    src: {
      type: String,
      default: '',
    },
    avatar: {
      type: String,
      default: ''
    }
  }
}
</script>

<style lang="less">
@import '../styles/vars.less';
.thumbnail {
  aspect-ratio: 16/9;

  &-default {
    width: 100%;
    height: 100%;
    background-color: @dark-color;
    border: 1px solid @primary-color;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    &-avatar {
      width: 40%;
    }

    &-tooltip {
      margin-top: 22px;
    }
  }

  &-image {
    width: 100%;
    height: 100%;
  }
}
</style>
